# lib.format

- **Type:** `'esm' | 'cjs' | 'umd' | 'mf' | 'iife'`
- **Default:** `'esm'`
- **CLI:** `--format <format>` (e.g. `--format umd`)

Specify the output format for the generated JavaScript output files.

For different output formats, Rslib uses the following default value of [output.library.type](https://rspack.rs/config/output#outputlibrarytype) provided by Rspack:

- `esm`：[modern-module](https://rspack.rs/config/output#type-modern-module)

::: info
You can enable Rspack experimental ESM output by setting [lib.experiments.advancedEsm](/config/lib/experiments#experimentsadvancedesm) to emit ESM output that is high-quality, more friendly to static analysis, and supports code splitting.
:::

- `cjs`：[commonjs-static](https://rspack.rs/config/output#type-commonjs-static)
- `umd`：[umd](https://rspack.rs/config/output#type-umd)
- `iife`: [modern-module](https://rspack.rs/config/output#type-modern-module) with [output.iife](https://rspack.rs/config/output#outputiife) enabled.

See [Output Format](/guide/basic/output-format) and [Module Federation](/guide/advanced/module-federation) for more details.

::: note

The `umd`, `mf` and `iife` formats only work when [bundle](/config/lib/bundle) is set to `true`.

:::
